package demo5;

//牛客网:字母收集
import java.util.Scanner;

// 注意类名必须为 Main, 不要有任何 package xxx 信息
public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        int m = in.nextInt();
        String[] map = new String[n+1];
        for(int i = 1; i<=n; i++) {
            map[i] = " "+in.next();
        }
        int[][] dp = new int[n+1][m+1];
        for(int i = 1; i<=n; i++) {
            for(int j = 1; j<=m; j++) {
                char ch = map[i].charAt(j);
                if(ch == 'l') dp[i][j] += 4;
                else if(ch == 'o') dp[i][j] += 3;
                else if(ch == 'v') dp[i][j] += 2;
                else if(ch == 'e') dp[i][j] += 1;
                dp[i][j] += Math.max(dp[i-1][j], dp[i][j-1]);
            }
        }
        System.out.println(dp[n][m]);
    }
}